{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "<a href=\"https://colab.research.google.com/drive/18gghD8RqO4zoZKft5WhhnhNOESCKUwWI?usp=sharing\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>"
      ],
      "metadata": {
        "id": "dHbI9sMsB_SM"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Multi-Agent Debate"
      ],
      "metadata": {
        "id": "EIebINimeeU0"
      }
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "id": "ZzT28SwY8In_"
      },
      "outputs": [],
      "source": [
        "!pip install -qU google-generativeai"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import google.generativeai as genai\n",
        "import getpass"
      ],
      "metadata": {
        "id": "8hcU9YNpem21"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "Get free-tier Google's Gemini API Key here: https://aistudio.google.com/app/apikey"
      ],
      "metadata": {
        "id": "JFuIg8etepWW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "API_KEY = getpass.getpass(\"Enter your Google API key: \")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "X3dy_sZxetx3",
        "outputId": "33f8652d-5c5a-45d7-a1dd-c9f1581d9e04"
      },
      "execution_count": 3,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Enter your Google API key: ··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "genai.configure(api_key=API_KEY)"
      ],
      "metadata": {
        "id": "bMpxL3CEeyUs"
      },
      "execution_count": 4,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "class DebateAgent:\n",
        "    \"\"\"Virtual agent with specific perspective\"\"\"\n",
        "    def __init__(self, name, perspective, model):\n",
        "        self.name = name\n",
        "        self.perspective = perspective\n",
        "        self.model = model\n",
        "        self.current_position = None\n",
        "\n",
        "    def propose_answer(self, question):\n",
        "        \"\"\"Step 1: Propose initial answer\"\"\"\n",
        "        prompt = f\"\"\"You are {self.name}, a virtual agent with this perspective: {self.perspective}\n",
        "\n",
        "        Question: {question}\n",
        "\n",
        "        From your perspective, provide your answer and reasoning:\"\"\"\n",
        "\n",
        "        response = self.model.generate_content(prompt).text\n",
        "        self.current_position = response.strip()\n",
        "        return self.current_position\n",
        "\n",
        "    def critique_others(self, question, other_positions):\n",
        "        \"\"\"Step 2: Critique other agents' positions\"\"\"\n",
        "        others_text = \"\\n\\n\".join([\n",
        "            f\"{agent_name}'s position:\\n{position}\"\n",
        "            for agent_name, position in other_positions.items()\n",
        "        ])\n",
        "\n",
        "        prompt = f\"\"\"You are {self.name} ({self.perspective})\n",
        "\n",
        "        Question: {question}\n",
        "\n",
        "        Other agents' positions:\n",
        "        {others_text}\n",
        "\n",
        "        Critically analyze their positions. Identify flaws, biases, or weaknesses:\"\"\"\n",
        "\n",
        "        response = self.model.generate_content(prompt).text\n",
        "        return response.strip()\n",
        "\n",
        "    def refine_position(self, question, critiques_received):\n",
        "        \"\"\"Step 3: Refine position based on critiques\"\"\"\n",
        "        critiques_text = \"\\n\\n\".join([\n",
        "            f\"Critique from {agent_name}:\\n{critique}\"\n",
        "            for agent_name, critique in critiques_received.items()\n",
        "        ])\n",
        "\n",
        "        prompt = f\"\"\"You are {self.name} ({self.perspective})\n",
        "\n",
        "        Question: {question}\n",
        "\n",
        "        Your current position:\n",
        "        {self.current_position}\n",
        "\n",
        "        Critiques you received:\n",
        "        {critiques_text}\n",
        "\n",
        "        Revise your position, addressing valid critiques:\"\"\"\n",
        "\n",
        "        response = self.model.generate_content(prompt).text\n",
        "        self.current_position = response.strip()\n",
        "        return self.current_position\n",
        "\n",
        "class MultiAgentDebate:\n",
        "    def __init__(self, num_agents=3):\n",
        "        self.model = genai.GenerativeModel(\"gemini-2.0-flash-exp\")\n",
        "        self.agents = []\n",
        "        self.debate_history = []\n",
        "\n",
        "    def add_agent(self, name, perspective):\n",
        "        \"\"\"Add a virtual agent to the debate\"\"\"\n",
        "        agent = DebateAgent(name, perspective, self.model)\n",
        "        self.agents.append(agent)\n",
        "\n",
        "    def debate(self, question, rounds=2):\n",
        "        \"\"\"Main debate process\"\"\"\n",
        "        print(f\"\\n{'='*60}\")\n",
        "        print(f\"🗣️  Multi-Agent Debate\")\n",
        "        print(f\"{'='*60}\")\n",
        "        print(f\"Question: {question}\\n\")\n",
        "\n",
        "        print(f\"Participants: {len(self.agents)} virtual agents\\n\")\n",
        "        for agent in self.agents:\n",
        "            print(f\"  • {agent.name}: {agent.perspective}\")\n",
        "        print()\n",
        "\n",
        "        # Initial proposals\n",
        "        print(f\"{'='*60}\")\n",
        "        print(f\"ROUND 1: Initial Proposals\")\n",
        "        print(f\"{'='*60}\\n\")\n",
        "\n",
        "        for agent in self.agents:\n",
        "            print(f\"👤 {agent.name}:\")\n",
        "            position = agent.propose_answer(question)\n",
        "            print(f\"{position}\\n\")\n",
        "\n",
        "        # Debate rounds\n",
        "        for round_num in range(2, rounds + 2):\n",
        "            print(f\"{'='*60}\")\n",
        "            print(f\"ROUND {round_num}: Critique & Refinement\")\n",
        "            print(f\"{'='*60}\\n\")\n",
        "\n",
        "            # Critique phase\n",
        "            print(f\"{'─'*60}\")\n",
        "            print(f\"Critique Phase\")\n",
        "            print(f\"{'─'*60}\\n\")\n",
        "\n",
        "            all_critiques = {}\n",
        "\n",
        "            for agent in self.agents:\n",
        "                # Get other agents' positions\n",
        "                other_positions = {\n",
        "                    a.name: a.current_position\n",
        "                    for a in self.agents if a != agent\n",
        "                }\n",
        "\n",
        "                print(f\"🔍 {agent.name} critiquing others...\")\n",
        "                critique = agent.critique_others(question, other_positions)\n",
        "                all_critiques[agent.name] = critique\n",
        "                print(f\"{critique[:150]}...\\n\")\n",
        "\n",
        "            # Refinement phase\n",
        "            print(f\"{'─'*60}\")\n",
        "            print(f\"Refinement Phase\")\n",
        "            print(f\"{'─'*60}\\n\")\n",
        "\n",
        "            for agent in self.agents:\n",
        "                # Get critiques directed at this agent\n",
        "                critiques_for_agent = {\n",
        "                    name: critique\n",
        "                    for name, critique in all_critiques.items()\n",
        "                    if name != agent.name\n",
        "                }\n",
        "\n",
        "                print(f\"✨ {agent.name} refining position...\")\n",
        "                refined = agent.refine_position(question, critiques_for_agent)\n",
        "                print(f\"{refined[:150]}...\\n\")\n",
        "\n",
        "        # Consensus building\n",
        "        print(f\"{'='*60}\")\n",
        "        print(f\"FINAL PHASE: Consensus Building\")\n",
        "        print(f\"{'='*60}\\n\")\n",
        "\n",
        "        final_answer = self.build_consensus(question)\n",
        "\n",
        "        print(f\"{'='*60}\")\n",
        "        print(f\"💡 CONSENSUS ANSWER\")\n",
        "        print(f\"{'='*60}\")\n",
        "        print(final_answer)\n",
        "        print()\n",
        "\n",
        "        return final_answer\n",
        "\n",
        "    def build_consensus(self, question):\n",
        "        \"\"\"Step 4: Build consensus from refined positions\"\"\"\n",
        "        all_positions = \"\\n\\n\".join([\n",
        "            f\"{agent.name}'s final position:\\n{agent.current_position}\"\n",
        "            for agent in self.agents\n",
        "        ])\n",
        "\n",
        "        prompt = f\"\"\"Question: {question}\n",
        "\n",
        "        Final positions from all agents:\n",
        "        {all_positions}\n",
        "\n",
        "        Synthesize these positions into a single, well-reasoned answer that:\n",
        "        1. Incorporates the strongest arguments\n",
        "        2. Addresses critiques and weaknesses\n",
        "        3. Provides the most factual and logical conclusion\n",
        "\n",
        "        Consensus answer:\"\"\"\n",
        "\n",
        "        response = self.model.generate_content(prompt).text\n",
        "        return response.strip()"
      ],
      "metadata": {
        "id": "tSrY1mR9e319"
      },
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Example 1: Fact-Checking\n",
        "print(\"=\"*60)\n",
        "print(\"EXAMPLE 1: Fact-Checking Through Debate\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate1 = MultiAgentDebate()\n",
        "debate1.add_agent(\"Skeptic\", \"Questions claims and demands evidence\")\n",
        "debate1.add_agent(\"Researcher\", \"Provides data-driven analysis\")\n",
        "debate1.add_agent(\"Synthesizer\", \"Integrates multiple perspectives\")\n",
        "\n",
        "debate1.debate(\n",
        "    \"Is coffee consumption good or bad for health?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 2: Complex Reasoning\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 2: Complex Policy Question\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate2 = MultiAgentDebate()\n",
        "debate2.add_agent(\"Economist\", \"Analyzes economic impacts and costs\")\n",
        "debate2.add_agent(\"Environmentalist\", \"Prioritizes ecological sustainability\")\n",
        "debate2.add_agent(\"Pragmatist\", \"Focuses on practical implementation\")\n",
        "\n",
        "debate2.debate(\n",
        "    \"Should cities ban gas-powered cars by 2030?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 3: Ethical Reasoning\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 3: Ethical Dilemma\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate3 = MultiAgentDebate()\n",
        "debate3.add_agent(\"Ethicist\", \"Applies moral philosophy and principles\")\n",
        "debate3.add_agent(\"Consequentialist\", \"Evaluates outcomes and consequences\")\n",
        "debate3.add_agent(\"Rights Advocate\", \"Prioritizes individual rights and freedoms\")\n",
        "\n",
        "debate3.debate(\n",
        "    \"Should AI-generated art be copyrightable?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 4: Scientific Hypothesis\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 4: Scientific Debate\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate4 = MultiAgentDebate()\n",
        "debate4.add_agent(\"Experimentalist\", \"Values empirical evidence and testing\")\n",
        "debate4.add_agent(\"Theorist\", \"Focuses on theoretical consistency\")\n",
        "debate4.add_agent(\"Critic\", \"Identifies methodological weaknesses\")\n",
        "\n",
        "debate4.debate(\n",
        "    \"Is dark matter the best explanation for galaxy rotation curves?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 5: Legal Reasoning\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 5: Legal Argument\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate5 = MultiAgentDebate()\n",
        "debate5.add_agent(\"Prosecutor\", \"Argues for strict liability\")\n",
        "debate5.add_agent(\"Defense\", \"Argues for protection of rights\")\n",
        "debate5.add_agent(\"Judge\", \"Seeks balanced interpretation of law\")\n",
        "\n",
        "debate5.debate(\n",
        "    \"Should social media companies be liable for user-generated content?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 6: Business Decision\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 6: Business Strategy Debate\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate6 = MultiAgentDebate()\n",
        "debate6.add_agent(\"Growth Strategist\", \"Prioritizes expansion and market share\")\n",
        "debate6.add_agent(\"Risk Manager\", \"Focuses on risk mitigation and stability\")\n",
        "debate6.add_agent(\"Customer Advocate\", \"Emphasizes customer value and satisfaction\")\n",
        "\n",
        "debate6.debate(\n",
        "    \"Should our startup pursue rapid growth through venture funding or slow organic growth?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "# Example 7: Reducing Hallucinations\n",
        "print(\"\\n\" + \"=\"*60)\n",
        "print(\"EXAMPLE 7: Fact Verification\")\n",
        "print(\"=\"*60)\n",
        "\n",
        "debate7 = MultiAgentDebate()\n",
        "debate7.add_agent(\"Fact Checker\", \"Verifies claims against known facts\")\n",
        "debate7.add_agent(\"Devil's Advocate\", \"Challenges assumptions and claims\")\n",
        "debate7.add_agent(\"Neutral Observer\", \"Seeks objective truth\")\n",
        "\n",
        "debate7.debate(\n",
        "    \"What are the proven health benefits of intermittent fasting?\",\n",
        "    rounds=2\n",
        ")\n",
        "\n",
        "\n",
        "print(\"✅ Multi-Agent Debate Complete!\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "PdLYfZk0gM84",
        "outputId": "84801d35-7448-4dd2-eff7-76bbd6e44978"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "============================================================\n",
            "EXAMPLE 1: Fact-Checking Through Debate\n",
            "============================================================\n",
            "\n",
            "============================================================\n",
            "🗣️  Multi-Agent Debate\n",
            "============================================================\n",
            "Question: Is coffee consumption good or bad for health?\n",
            "\n",
            "Participants: 3 virtual agents\n",
            "\n",
            "  • Skeptic: Questions claims and demands evidence\n",
            "  • Researcher: Provides data-driven analysis\n",
            "  • Synthesizer: Integrates multiple perspectives\n",
            "\n",
            "============================================================\n",
            "ROUND 1: Initial Proposals\n",
            "============================================================\n",
            "\n",
            "👤 Skeptic:\n",
            "Alright, another health claim. Let's not jump to conclusions here. The question is whether coffee consumption is *good or bad* for health. That's a pretty broad statement, implying a universal truth.\n",
            "\n",
            "First, we need to define \"coffee consumption.\" Are we talking about a single espresso a day, or a pot of black coffee? Are we adding sugar, cream, or artificial sweeteners? The answer likely changes drastically depending on the quantity and preparation methods.\n",
            "\n",
            "Second, \"good or bad\" is a gross oversimplification. Health outcomes are complex and multifaceted. Coffee consumption could be beneficial for one person and detrimental to another. Factors like genetics, pre-existing conditions, other dietary habits, and lifestyle all play a role.\n",
            "\n",
            "Third, we need *evidence*. What kind of studies are we looking at? Observational studies? Randomized controlled trials? What are the sample sizes? What are the methodologies? Were there any potential biases? Correlation does not equal causation. We need to see rigorous, peer-reviewed research before drawing any firm conclusions.\n",
            "\n",
            "Until I see compelling evidence addressing these points, my answer is: **It depends.** Coffee consumption *might* have some benefits for some people under certain circumstances, and it *might* have some drawbacks for others. A blanket statement of \"good\" or \"bad\" is scientifically irresponsible without considering a multitude of variables and rigorously analyzing the available data. Show me the robust, well-controlled, bias-free evidence, and *then* we can talk.\n",
            "\n",
            "👤 Researcher:\n",
            "Okay, here's a data-driven analysis of the question: \"Is coffee consumption good or bad for health?\"\n",
            "\n",
            "**Answer:** Overall, moderate coffee consumption (around 3-4 cups per day) appears to be associated with more health benefits than risks for most people. However, individual responses vary, and excessive consumption can be detrimental.\n",
            "\n",
            "**Reasoning:**\n",
            "\n",
            "1.  **Mortality:** Many large-scale observational studies have consistently shown an inverse association between coffee consumption and all-cause mortality. This means coffee drinkers tend to live longer. For example:\n",
            "\n",
            "    *   A 2018 meta-analysis published in the *British Medical Journal*, including data from over 40 studies, found that coffee consumption was associated with a lower risk of death from all causes, cardiovascular disease, and several types of cancer.\n",
            "    *   A large study published in the *Annals of Internal Medicine* in 2017, which followed over 500,000 people in 10 European countries, found that higher coffee consumption was associated with a lower risk of death from various causes.\n",
            "\n",
            "2.  **Specific Health Benefits:**\n",
            "\n",
            "    *   **Reduced Risk of Type 2 Diabetes:** Numerous studies demonstrate that coffee consumption is associated with a lower risk of developing type 2 diabetes. Possible mechanisms include improvements in insulin sensitivity and glucose metabolism.\n",
            "    *   **Neuroprotective Effects:** Coffee consumption is linked to a lower risk of neurodegenerative diseases like Parkinson's disease and Alzheimer's disease. Caffeine and other compounds in coffee may protect brain cells from damage.\n",
            "    *   **Liver Health:** Coffee appears to have a protective effect on the liver, reducing the risk of liver cirrhosis and liver cancer.\n",
            "    *   **Cardiovascular Health:** While there was initial concern about coffee and heart health, more recent and robust evidence suggests that moderate consumption is not associated with an increased risk of cardiovascular disease. Some studies even suggest a possible protective effect against heart failure and stroke.\n",
            "    *   **Mental Health:** Coffee consumption may be associated with a lower risk of depression.\n",
            "\n",
            "3.  **Potential Risks and Downsides:**\n",
            "\n",
            "    *   **Anxiety and Insomnia:** Caffeine is a stimulant and can cause anxiety, nervousness, and insomnia, especially in sensitive individuals or when consumed in large amounts.\n",
            "    *   **Increased Blood Pressure:** Caffeine can cause a temporary increase in blood pressure. While this is usually not a problem for most people, those with uncontrolled hypertension should be cautious.\n",
            "    *   **Pregnancy:** High caffeine intake during pregnancy has been linked to adverse outcomes, such as low birth weight and preterm birth. Current recommendations suggest limiting caffeine intake to 200 mg per day during pregnancy.\n",
            "    *   **Drug Interactions:** Coffee can interact with certain medications.\n",
            "    *   **Addiction and Withdrawal:** Caffeine is addictive, and sudden cessation can lead to withdrawal symptoms like headaches, fatigue, and irritability.\n",
            "    *   **Heartburn/Acid Reflux:** Coffee can worsen symptoms of heartburn or acid reflux in some people.\n",
            "\n",
            "4.  **Individual Variability:**\n",
            "\n",
            "    *   **Genetics:** Genetic variations can influence how quickly individuals metabolize caffeine, affecting their sensitivity to its effects. Some people are \"fast metabolizers\" and can tolerate high doses of caffeine without significant side effects, while others are \"slow metabolizers\" and are more sensitive to its effects.\n",
            "    *   **Health Conditions:** Individuals with certain health conditions, such as anxiety disorders, heart arrhythmias, or gastrointestinal problems, may need to limit or avoid coffee consumption.\n",
            "    *   **Tolerance:** Regular coffee drinkers develop a tolerance to caffeine, meaning they need to consume more to achieve the same effects.\n",
            "\n",
            "**Important Considerations:**\n",
            "\n",
            "*   **Type of Coffee:** The health effects of coffee can vary depending on the type of coffee (e.g., filtered vs. unfiltered, espresso vs. drip), as well as the addition of sugar, cream, and other additives.\n",
            "*   **Moderation is Key:** Most of the health benefits associated with coffee consumption are observed with moderate intake. Excessive consumption can increase the risk of adverse effects.\n",
            "*   **Consult a Healthcare Professional:** Individuals with specific health concerns should consult with their doctor or a registered dietitian to determine if coffee consumption is appropriate for them.\n",
            "\n",
            "**In conclusion, the scientific evidence generally supports the notion that moderate coffee consumption is more beneficial than harmful for most people. However, it's crucial to be mindful of individual responses and potential risks and to consume coffee in moderation as part of a healthy lifestyle.**\n",
            "\n",
            "👤 Synthesizer:\n",
            "Okay, let's tackle the question of whether coffee consumption is good or bad for health. The most accurate answer is: **it's complex, and it depends on various factors, but generally, moderate coffee consumption appears to offer more potential benefits than risks for many people.**\n",
            "\n",
            "Here's the reasoning, integrating multiple perspectives:\n",
            "\n",
            "*   **The Proponents' Perspective (Potential Benefits):**\n",
            "\n",
            "    *   **Antioxidants:** Coffee is rich in antioxidants, which can help protect the body against damage from free radicals, potentially reducing the risk of chronic diseases like some cancers and heart disease.\n",
            "    *   **Brain Function:** Caffeine, the active ingredient in coffee, is a stimulant that can improve alertness, focus, and cognitive function. It can also enhance memory and reaction time.\n",
            "    *   **Physical Performance:** Caffeine can enhance athletic performance by increasing adrenaline levels and mobilizing fatty acids.\n",
            "    *   **Disease Prevention:** Studies have linked coffee consumption to a reduced risk of type 2 diabetes, Parkinson's disease, Alzheimer's disease, liver diseases (including cirrhosis and liver cancer), and heart failure.\n",
            "    *   **Mood Enhancement:** Coffee can stimulate the release of neurotransmitters like dopamine and serotonin, which can improve mood and well-being.\n",
            "\n",
            "*   **The Opponents' Perspective (Potential Risks):**\n",
            "\n",
            "    *   **Anxiety and Insomnia:** Caffeine can cause anxiety, nervousness, and insomnia, especially in people sensitive to its effects or when consumed in large quantities or close to bedtime.\n",
            "    *   **Digestive Issues:** Coffee can stimulate gastric acid production, potentially leading to heartburn, acid reflux, and stomach upset in some individuals.\n",
            "    *   **Addiction and Withdrawal:** Caffeine is addictive, and regular coffee drinkers may experience withdrawal symptoms like headaches, fatigue, and irritability if they suddenly stop consuming it.\n",
            "    *   **Heart Problems:** In some individuals, high doses of caffeine can cause palpitations, increased heart rate, and elevated blood pressure. People with pre-existing heart conditions should exercise caution.\n",
            "    *   **Pregnancy Concerns:** High caffeine intake during pregnancy has been linked to an increased risk of miscarriage, premature birth, and low birth weight. Current guidelines recommend limiting caffeine intake to 200mg per day during pregnancy.\n",
            "    *   **Drug Interactions:** Coffee can interact with certain medications, either increasing or decreasing their effectiveness.\n",
            "\n",
            "*   **The Moderation Perspective (Individual Factors and Moderation are Key):**\n",
            "\n",
            "    *   **Individual Tolerance:** People vary in their sensitivity to caffeine. Some can tolerate several cups of coffee without experiencing adverse effects, while others may be highly sensitive to even small amounts.\n",
            "    *   **Underlying Health Conditions:** The effects of coffee can be different for people with pre-existing health conditions. For example, people with anxiety disorders, heart problems, or digestive issues may need to limit or avoid coffee consumption.\n",
            "    *   **Dosage Matters:** Most studies suggest that moderate coffee consumption (around 3-4 cups per day) is generally safe and may even be beneficial. However, excessive consumption can increase the risk of adverse effects.\n",
            "    *   **Timing Matters:** Consuming coffee too late in the day can interfere with sleep.\n",
            "    *   **Type of Coffee and Additives:** The type of coffee (e.g., filtered vs. unfiltered) and the addition of sugar, cream, or artificial sweeteners can affect its healthfulness. Black coffee is generally considered the healthiest option.\n",
            "    *   **Genetics:** Genetic factors can influence how individuals metabolize caffeine and respond to its effects.\n",
            "\n",
            "*   **The Scientific Consensus (evolving evidence):**\n",
            "\n",
            "    *   While there are still some uncertainties, the overall body of scientific evidence suggests that moderate coffee consumption is not harmful and may even be beneficial for many people. However, more research is needed to fully understand the long-term effects of coffee on health and to identify specific subgroups of people who may be more likely to experience adverse effects.\n",
            "\n",
            "**In conclusion:**\n",
            "\n",
            "Coffee consumption is not a simple \"good\" or \"bad\" issue. A balanced perspective considers the potential benefits and risks, taking into account individual factors, moderation, and underlying health conditions. For most healthy adults, moderate coffee consumption appears to be a safe and potentially beneficial habit. However, it's essential to listen to your body, be mindful of your caffeine intake, and consult with a healthcare professional if you have any concerns.\n",
            "\n",
            "============================================================\n",
            "ROUND 2: Critique & Refinement\n",
            "============================================================\n",
            "\n",
            "────────────────────────────────────────────────────────────\n",
            "Critique Phase\n",
            "────────────────────────────────────────────────────────────\n",
            "\n",
            "🔍 Skeptic critiquing others...\n",
            "Okay, let's put on our skeptical hats and analyze these positions on coffee consumption.\n",
            "\n",
            "**Researcher's Position - Strengths:**\n",
            "\n",
            "*   **Data-Driven:**...\n",
            "\n",
            "🔍 Researcher critiquing others...\n",
            "Okay, let's analyze the positions of the Skeptic and the Synthesizer regarding coffee consumption.\n",
            "\n",
            "**Skeptic's Position: Strengths and Weaknesses**\n",
            "\n",
            "...\n",
            "\n",
            "🔍 Synthesizer critiquing others...\n",
            "Okay, let's analyze these two positions on coffee consumption:\n",
            "\n",
            "**Skeptic's Position:**\n",
            "\n",
            "*   **Strengths:** The skeptic brings up crucial points about...\n",
            "\n",
            "────────────────────────────────────────────────────────────\n",
            "Refinement Phase\n",
            "────────────────────────────────────────────────────────────\n",
            "\n",
            "✨ Skeptic refining position...\n",
            "Okay, I hear the critiques. My previous response was perhaps *too* skeptical, verging on analysis paralysis and dismissing existing research premature...\n",
            "\n",
            "✨ Researcher refining position...\n",
            "Okay, here's a revised data-driven analysis of the question: \"Is coffee consumption good or bad for health?\" incorporating the critiques received from...\n",
            "\n",
            "✨ Synthesizer refining position...\n",
            "Okay, taking both the Skeptic and the Researcher's critiques to heart, here's a revised position on the question of whether coffee consumption is good...\n",
            "\n",
            "============================================================\n",
            "ROUND 3: Critique & Refinement\n",
            "============================================================\n",
            "\n",
            "────────────────────────────────────────────────────────────\n",
            "Critique Phase\n",
            "────────────────────────────────────────────────────────────\n",
            "\n",
            "🔍 Skeptic critiquing others...\n",
            "Okay, let's analyze the positions of the Researcher and the Synthesizer regarding the health effects of coffee consumption, focusing on flaws, biases,...\n",
            "\n",
            "🔍 Researcher critiquing others...\n",
            "Okay, let's critically analyze the positions of both the Researcher and the Synthesizer regarding the health effects of coffee consumption.\n",
            "\n",
            "**Researc...\n",
            "\n",
            "🔍 Synthesizer critiquing others...\n",
            "Okay, here's a critical analysis of the Skeptic, Researcher, and Synthesizer positions on the question of whether coffee consumption is good or bad fo...\n",
            "\n",
            "────────────────────────────────────────────────────────────\n",
            "Refinement Phase\n",
            "────────────────────────────────────────────────────────────\n",
            "\n",
            "✨ Skeptic refining position...\n",
            "Okay, I appreciate the thorough critiques. It's clear that while I've improved from my initial overly skeptical stance, I'm still leaning too heavily ...\n",
            "\n",
            "✨ Researcher refining position...\n",
            "Okay, here's a further revised position, addressing the valid critiques from both the Skeptic and the Synthesizer. The goal is to be more rigorous, av...\n",
            "\n",
            "✨ Synthesizer refining position...\n",
            "Okay, taking both the Skeptic and the Researcher's critiques to heart, here's a further revised position on the question of whether coffee consumption...\n",
            "\n",
            "============================================================\n",
            "FINAL PHASE: Consensus Building\n",
            "============================================================\n",
            "\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "Vbw3YZS1gWvP"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}